
/**
 * Default implementation of the PacketExtension interface. Unless a PacketExtensionProvider
 * is registered with {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager},
 * instances of this class will be returned when getting packet extensions.<p>
 *
 * This class provides a very simple representation of an XML sub-document. Each element
 * is a key in a Map with its CDATA being the value. For example, given the following
 * XML sub-document:
 *
 * <pre>
 * &lt;foo xmlns="http://bar.com"&gt;
 *     &lt;color&gt;blue&lt;/color&gt;
 *     &lt;food&gt;pizza&lt;/food&gt;
 * &lt;/foo&gt;</pre>
 *
 * In this case, getValue("color") would return "blue", and getValue("food") would
 * return "pizza". This parsing mechanism mechanism is very simplistic and will not work
 * as desired in all cases (for example, if some of the elements have attributes. In those
 * cases, a custom PacketExtensionProvider should be used.
 *
 * @author Matt Tucker
 */
class DefaultPacketExtension : public PacketExtension {
public:	
	
    /**
     * Creates a new generic packet extension.
     *
     * @param elementName the name of the element of the XML sub-document.
     * @param namespace the namespace of the element.
     */
    DefaultPacketExtension(std::string & elementName, std::string & nameSpace) : 
		elementName(elementName),
		nameSpace(nameSpace)
	{}
	
    /**
     * Returns the XML element name of the extension sub-packet root element.
     *
     * @return the XML element name of the packet extension.
     */
	std::string & getElementName() {
        return elementName;
    }

    /**
     * Returns the XML namespace of the extension sub-packet root element.
     *
     * @return the XML namespace of the packet extension.
     */
	std::string & getNamespace() {
        return nameSpace;
    }
	
	std::string toXML() ;
	
    /**
     * Returns an unmodifiable collection of the names that can be used to get
     * values of the packet extension.
     *
     * @return the names.
     */
	std::vector<std::string> getNames() ;

    /**
     * Returns a packet extension value given a name.
     *
     * @param name the name.
     * @return the value.
     */
	std::string getValue(std::string & name);
	
    /**
     * Sets a packet extension value using the given name.
     *
     * @param name the name.
     * @param value the value.
     */
    void setValue(std::string & name, std::string & value);
	
private:
	std::string elementName;
	std::string nameSpace;
	std::map<std::string, std::string> _map;

};
